package composer

import (
	"io"
)

type Executer func() error

type Closer interface {
	io.Closer
}

type Listener interface {
	Closer
	Listen() error
}

type Register interface {
	AttachListener(listener Listener)
	Attach(exec Executer)
}
type register struct {
	index int

	*composer
}

func (r *register) AttachListener(listener Listener) {
	for _, v := range r.composer.listeners {
		if v == listener {
			return
		}
	}
	r.composer.listeners = append(r.composer.listeners, listener)
}

func (r *register) Attach(exec Executer) {
	r.composer.executers = append(r.composer.executers, exec)
}
